﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Objects;
using System.Collections.Generic;
using BAL;

public partial class Admin_UCControls_UCDuyet : System.Web.UI.UserControl
{
    public static Duyet itemDuyet;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetDanhSachChoDuyet(Convert.ToInt16(Common.Myconst.MOITAO.ToString()));
        }
    }

    public static List<DanhSachChoDuyet> ListDuyet = new List<DanhSachChoDuyet>();


    private void GetDanhSachChoDuyet(int idTrangThaiDuyet)
    {
        ListDuyet = BALDanhSachChoDuyet.GetAllItem(idTrangThaiDuyet);

        if (ListDuyet.Count > 0)
        {
            GridDuyet.DataSource = ListDuyet;
        }
        GridDuyet.PageIndex = 0;
        //GridDuyet.Sort("NgayDangKy",SortDirection.Descending);
        GridDuyet.DataBind();
    }

    protected void GridDuyet_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Duyet")
        {

            foreach (DanhSachChoDuyet Item in ListDuyet)
            {
                if (Item.Id == Convert.ToInt16(e.CommandArgument))
                {
                    Session.Add("ItemDuyet", Item);
                }
            }

            Response.Redirect("../Admin/Duyet_Update.aspx");

        }

    }

    protected void GridDuyet_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridDuyet.DataSource = ListDuyet;
        GridDuyet.PageIndex = e.NewPageIndex;
        GridDuyet.DataBind();
    }
}
